home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8614 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: f;oating point precision
  5. Date: Tue, 05 Mar 96 12:10:30 GMT
  6. Organization: none
  7. Message-ID: <826027830snz@genesis.demon.co.uk>
  8. References: <c0d_9603050128@csource.blaze.net.au>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <c0d_9603050128@csource.blaze.net.au>
  15.            David.Burrows@f158.n633.z3.fidonet.org "David Burrows" writes:
  16.  
  17. >Help.... I am getting floating point innaccuracies at about the 4th decimal
  18. >
  19. >place. eg i enter 510.0250 and it comes out as 510.0249.
  20. >I am just starting to learn c so please excuse my ignorance.
  21.  
  22. You don't give anyindication of what your code does or what (precise)
  23. types of variable it uses so any answer to your question can only be a guess.
  24.  
  25. That corresponds to an error in the 7th significant digit which is all you
  26. can expect from float variables. If you want more precision you should
  27. use double. Floating point errors are cumulative so if you are performing
  28. a long calculation (such as in a loop) your results will become
  29. progressively less precise.
  30.  
  31. -- 
  32. -----------------------------------------
  33. Lawrence Kirby | fred@genesis.demon.co.uk
  34. Wilts, England | 70734.126@compuserve.com
  35. -----------------------------------------
  36.